//
//  GenTranDataXml.m
//  SendGzipData
//
//  Created by URANUS on 15/4/13.
//  Copyright (c) 2015年 URANUS. All rights reserved.
//

#import "GenTranDataXml.h"

@implementation GenTranDataXml

+ (NSString *) validString:(NSString *) value{
    NSString *returnValue;
    
    if ( value != nil) {
        returnValue = value;
    }else{
        returnValue = @"";
    }
    
    return returnValue;
}

+ (NSString *) genXmlWithTransData: (TransData *) transData andOutputData: (NSString *) outputData {
    NSString *value;
    NSMutableString *xmlString = [[NSMutableString alloc] init];
    [xmlString appendString:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><TransData><BaseInfo>"];
    [xmlString appendString:@"<TransType>"];
    value = transData.transType;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</TransType>"];
    [xmlString appendString:@"<TransCode>"];
    value = transData.transCode;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</TransCode>"];
    [xmlString appendString:@"<SubTransCode>"];
    value = transData.subTransCode;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</SubTransCode>"];
    [xmlString appendString:@"<UserName>"];
    value = transData.userName;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</UserName>"];
    [xmlString appendString:@"<Password>"];
    value = transData.password;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</Password>"];
    [xmlString appendString:@"<ResultCode>"];
    value = transData.resultCode;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</ResultCode>"];
    [xmlString appendString:@"<ResultMsg>"];
    value = transData.resultMsg;
    value = [self validString:value];
    [xmlString appendString:value];
    [xmlString appendString:@"</ResultMsg>"];
    [xmlString appendString:@"</BaseInfo>"];
    [xmlString appendString:@"<OutputData>"];
    value = [self validString:outputData];
    [xmlString appendString:value];
    [xmlString appendString:@"</OutputData>"];
    [xmlString appendString:@"</TransData>"];
    return xmlString;
}

@end
